<template>
    <div class="news-lastest pt10">
        <div class="news-lastest-list">
            <template v-for="(item,index) in list" :key="index">
                <div class="news-lastest-item">
                    <div class="news-lastest-item-img img2">
                        <img :src="item.cover" alt="" style="width: 100%;height: 100%;">
                    </div>
                    <div class="news-lastest-item-content content2">
                        <p style="font-size: 10px;line-height: 10px;">
                            <span style="color: #9a9a9a;">{{ item.title }}</span>
                        </p>
                        <p class="contentTxt2">
                            {{ item.content }}
                        </p>
                        <p style="font-size: 10px;line-height: 16px;margin-bottom: 5px;color: #9a9a9a;">
                            {{ item.game_description }}
                        </p>
                        <p style="font-size: 10px;line-height: 10px;">
                            <span style="font-weight: 600;">HAREM HEROES‧{{ item.created_at }}</span>
                        </p>
                    </div>
                </div>
                <nut-divider style="color: #9a9a9a;"></nut-divider>
            </template>
        </div>
    </div>
</template>

<script setup lang="ts">
import {axiosService} from "@http";
import {onBeforeMount, ref} from "vue";

export interface YxListInterface {
    items: YxListItemInterface[]
    total_items: number
    limit: number
    first: number
    previous: number
    current: number
    next: number
    last: number
}

export interface YxListItemInterface {
    id: number
    title: string
    cover: string
    game_name: string
    game_description: string
    content: string
    type: number
    created_at: string
    status: number
}

const list = ref<YxListItemInterface[]>([])

const getYxList =  async (typeId:number) => {
    const data = {
        type: typeId, //1游戏更新 2限时活动
        page:1, //分也
        game_id: 1,// 游戏id
        size: 9999
    }
    const res = await axiosService.post<YxListInterface>('/api/Article/bulletinList',data)
    if(res.code === 200 && res.data) return res.data.items
    return []
}


onBeforeMount(async ()=> {
    list.value = await getYxList(1)
})


</script>

<style scoped lang="scss">

.news-box {
    padding: 7px;

    .news-title {
        font-weight: 600;
        font-size: 15px;
        margin-top: 0;
        margin-bottom: 5px;
    }

    .news-content {
        font-size: 10px;
        line-height: 17px;
    }
}

.news-lastest {
    padding: 0 14px;
    margin-bottom: 20px;

    .news-lastest-item {
        display: flex;
        margin-bottom: 15px;

        .news-lastest-item-img {
            width: 147px;
            height: 73px;
            flex-grow: 0;
            &.img2{
                width: 75px;
                height: 75px;
            }
        }

        .news-lastest-item-content {
            // flex-grow: 1;
            width: calc(100% - 147px);
            padding: 0 10px;

            &.content2{
                width: calc(100% - 75px);
            }

            .contentTxt2{
                font-size: 10px;
                font-weight: 600;
                line-height: 16px;
                margin-top: 2px;
                width: 100%;
                white-space: nowrap;
                overflow: hidden;
                text-overflow: ellipsis;
            }

            .contentTxt {
                font-size: 11px;
                font-weight: 600;
                line-height: 18px;
                margin-top: 9px;
                margin-bottom: 9px;
                width: 100%;
                white-space: normal;
                overflow: hidden;
                display: -webkit-box;
                text-overflow: ellipsis;
                -webkit-line-clamp: 2;
                /* 控制行数 */
                -webkit-box-orient: vertical;
            }
        }
    }
}


.game-btn {
    display: flex;
    justify-content: center;
    padding-top: 10px;

    .download-btn {
        width: 180px;
        background-color: #4960eb;
        color: #fff;
        border-radius: 20px;
        height: 33px;
        font-size: 13px;
        font-weight: bold;
        line-height: 33px;
        text-align: center;
    }
}
</style>
